﻿using System.Text;
using System.Threading.Tasks;
using WeiboWPSdk.Json;
using WeiboWPSdk.ResponseEntity;

namespace WeiboWPSdk.Api {
    public class RegisterApi : ApiBase {
        public RegisterApi(ClientHttpHelper httpHelper)
            : base(httpHelper) {
        }

        #region 读取接口
        /// <summary>
        /// 验证昵称是否可用，并给予建议昵称
        /// http://open.weibo.com/wiki/2/register/verify_nickname
        /// </summary>
        /// <param name="nickname">需要验证的昵称。4-20个字符，支持中英文、数字、"_"或减号。必须做URLEncode，采用UTF-8编码。</param>
        /// <returns></returns>
        public async Task<NicknameVerifyResult> VerifyNicknameAsync(string nickname) {
            var json = await HttpHelper.GetBasicCommandAsync("register/verify_nickname", new WeiboParameter("nickname", nickname));
            return JsonConvert.DeserializeObject<NicknameVerifyResult>(json);
        }
        #endregion
    }
}
